package com.fortune.cat

import com.fortune.cat.filter.factory.AbstractCustomizeGatewayFilterFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.cloud.gateway.filter.GatewayFilterChain
import org.springframework.stereotype.Component
import org.springframework.web.server.ServerWebExchange
import reactor.core.publisher.Mono

/**
 * @author zhaozeyang
 * @date 2019/4/18 19:25
 * @description
 */
@Component
class TestGroovyFilter extends AbstractCustomizeGatewayFilterFactory<TestGroovyFilter.Config> {

    private Logger log=LoggerFactory.getLogger(TestGroovyFilter.class)

    TestGroovyFilter() {
        super(Config.class)
    }

    @Override
    protected Mono<Void> doApply(Config config, ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("it my TestGroovyFilter")
        return chain.filter(exchange)
    }

    @Override
    protected int doGetOrder() {
        return 0
    }

    @Override
    protected boolean skipPresent(Config config, ServerWebExchange exchange) {
        return false
    }

    static class Config{

    }

}
